import {request} from '/@/utils/service';
import {UserPageQuery, AddReq, EditReq, InfoReq} from '@fast-crud/fast-crud';

export const apiPrefix = '/api/system/menu/';

export function GetList(query: UserPageQuery) {
    return request({
        url: apiPrefix,
        method: 'get',
        params: query,
    });
}

export function GetObj(id: InfoReq) {
    return request({
        url: apiPrefix + id + '/',
        method: 'get',
    });
}

export function AddObj(obj: AddReq) {
    return request({
        url: apiPrefix,
        method: 'post',
        data: obj,
    });
}

export function UpdateObj(obj: EditReq) {
    return request({
        url: apiPrefix + obj.id + '/',
        method: 'put',
        data: obj,
    });
}

export function DelObj(id: string | number) {
    return request({
        url: apiPrefix + id + '/',
        method: 'delete',
    });
}

export function GetAllMenu(query: UserPageQuery) {
    return request({
        url: apiPrefix + 'get_all_menu/',
        method: 'get',
        params: query,
    });
}

export function lazyLoadMenu(id: String,status: Boolean) {
    return request({
        url: '/api/spider/info/agent',
        method: 'get',
        params: {
            key: id,
            pageSize: 20033,
            is_running: status,
        }
    });
}

export function getAgentList(query: UserPageQuery) {
    return request({
        url: '/api/spider/info/agent',
        method: 'get',
        params: query
    });
}

export function getAgentYears(params: UserPageQuery) {
    return request({
        url: '/api/spider/info/years',
        method: 'get',
        params: params
    });
}

export function getCrawlLog(id: BigInt) {
    return request({
        url: '/api/spider/info/agentTaskMonitor',
        method: 'get',
        params: {
            id: id,
        }
    });
}

export function getRecord(query: UserPageQuery) {
    return request({
        url: '/api/spider/info/record',
        method: 'get',
        params: query
    });
}

export function getStatistics(query: UserPageQuery) {
    return request({
        url: '/api/spider/info/statistic',
        method: 'get',
        params: query
    });
}

export function getDocuments(query: UserPageQuery) {
    return request({
        url: '/api/spider/info/document',
        method: 'get',
        params: query
    });
}
